﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class User_ChangePwd : System.Web.UI.Page
{
    Datacon dataconn = new Datacon();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection cn = dataconn.getcon();
            cn.Open();

            SqlDataReader dr;
            string sql = "select a.bumenmingcheng as bumenmingcheng from bumeng a, Student b Where a.id=b.bumenid and b.kaoshenghao=" + Session["kaoshenghao"].ToString();
            SqlCommand myCommand = new SqlCommand(sql, cn);
            dr = myCommand.ExecuteReader();
            if (dr.Read())
            {
                Label3.Text = dr["bumenmingcheng"].ToString();
            }

            sql = "select a.danweimingchen as danweimingchen from danwei a, Student b Where a.id=b.danweiid and b.kaoshenghao=" + Session["kaoshenghao"].ToString();
            myCommand.CommandText = sql;
            dr.Close();
            cn.Close();
            cn.Open();
            dr = myCommand.ExecuteReader();
            if (dr.Read())
            {
                Label1.Text = dr["danweimingchen"].ToString();
            }
            cn.Close();
            dataconn.ecDropDownList(DropDownList1, "select a.id as id ,a.bumenmingcheng as bumenmingcheng from bumeng a,Student c  where  c.kaoshenghao=" + Session["kaoshenghao"].ToString() + " and c.danweiid=a.danweiid", "bumenmingcheng", "id");

        }

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

        {
            SqlConnection cn = dataconn.getcon();
            cn.Open();
            String pwd = "";
            SqlDataReader dr;
            string sql = "Update Student Set bumenid='" + DropDownList1.SelectedValue + "' Where kaoshenghao='" + Session["kaoshenghao"].ToString() + "'";
            SqlCommand myCommand = new SqlCommand(sql, cn);
            dr = myCommand.ExecuteReader();

            sql = "select a.bumenmingcheng as bumenmingcheng from bumeng a, Student b Where a.id=b.bumenid and b.kaoshenghao=" + Session["kaoshenghao"].ToString();
            myCommand.CommandText = sql;
            dr.Close();
            cn.Close();
            cn.Open();
            dr = myCommand.ExecuteReader();
            if (dr.Read())
            {
                Label3.Text = dr["bumenmingcheng"].ToString();
            }
            cn.Close();
            //Response.Write("<script>alert('修改成功！')</script>");


        }


    }
    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        Response.Write("<script>window.location.href='or.aspx'</script>");
    }
}